package com.ruoyi.web.pojo.dto.stock;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Objects;

/**
 * 入库明细对象 storage
 * 
 * @author zq
 * @date 2024-01-06
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class StorageExcel
{
    /** 用户ID */
    @Excel(name ="记录账户")
    private String userId;

    /** 创建者 */
    @Excel(name ="账户名称")
    private String createBy;

    /** 产品类型 */
    @Excel(name = "产品类型")
    private String type;

    /** 产品名称 */
    @Excel(name = "产品名称")
    private String product;


    /** 数量 */
    @Excel(name = "数量")
    private Float number;

    /** 单位 */
    @Excel(name = "单位")
    private String unit;

    /** 创建时间 */
    @Excel(name = "入库日期")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private String createTime;

    public StorageExcel(StorageRep storage) {
        if (Objects.isNull(storage)){
            return;
        }
        this.userId= storage.getUserId();
        switch (storage.getType()){
            case "1":
                this.setType("农资");
                break;
            case "2":
                this.setType("农产品");
                break;
            case "3":
                this.setType("机械设备");
                break;
            case "4":
                this.setType("其他");
                break;
        }
        this.product=storage.getProduct();
        this.number=storage.getNumber();
        this.unit= storage.getUnit();
        this.createBy = storage.getCreateBy();
        if (Objects.nonNull(storage.getCreateTime())){
            this.createTime = DateUtils.getConvertFormat(storage.getCreateTime());
        }
    }

}
